-
Notifications
You must be signed in to change notification settings - Fork 32
Correctly call live/historic prices for rest #548
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Here's the code health analysis summary for commits Analysis Summary
Code Coverage Report
|
777459b to
6727d4f
Compare
|
|
||
| def get_closes_websocket(self, trade_pairs: List[TradePair], trade_pair_to_last_order_time_ms) -> dict[str: PriceSource]: | ||
| def get_closes_websocket(self, trade_pairs: List[TradePair], time_ms) -> dict[str: PriceSource]: | ||
| events = {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice cleanup!
|
|
||
| def time_delta_from_now_ms(self, now_ms: int) -> int: | ||
| def time_delta_from_now_ms(self, now_ms:int = None) -> int: | ||
| if not now_ms: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice fix. this could have caused errors
neurons/validator.py
Outdated
| ) | ||
|
|
||
| price_sources = self.live_price_fetcher.get_sorted_price_sources_for_trade_pair(trade_pair, now_ms) | ||
| price_sources = self.live_price_fetcher.get_sorted_price_sources_for_trade_pair(trade_pair) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not pass the time from before? It is the closest timestamp to the order received time as possible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The data services check whether or not there is any value assigned to time_ms, so even if the timestamp is right now, it will try to retrieve historical data. It looked like the validator was trying to fetch live data, so to call the same endpoint live endpoint it called before, I passed in None.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The goal of this code segment is to get the price closest to the price when the order was received by the validator. That's why the code passed "now_ms" to get_sorted_price_sources_for_trade_pair. By using the current time, it will be a little bit in the future compared to when the order was placed.
| bars_df = cls.get_bars_with_features(trade_pair, processed_ms, adv_lookback_window, calc_vol_window) | ||
| row_selected = bars_df.iloc[-1] | ||
| annualized_volatility = row_selected['annualized_vol'] | ||
| annualized_volatility = row_selected['annualized_vol'] # recalculate slippage false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unsure what this comment means
neurons/backtest_manager.py
Outdated
| secrets = ValiUtils.get_secrets() # {'polygon_apikey': '123', 'tiingo_apikey': '456'} | ||
| btm = BacktestManager(hk_to_positions, start_time_ms, secrets, None, capital=500_000, | ||
| use_slippage=True, fetch_slippage_data=False, recalculate_slippage=False, | ||
| use_slippage=True, fetch_slippage_data=True, recalculate_slippage=True, # recalculate slippage fetch slippage data originally false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are these changes necessary or is it only for the local testing
35ed251 to
6deb4ef
Compare
02765d7 to
5671c2a
Compare
🤖 Claude AI Code ReviewLast reviewed on: 14:23:47 SummaryThis PR unifies timestamp handling for historic vs. live price calls across data services. The main changes involve:
✅ Strengths
|
5671c2a to
13bb765
Compare
https: //github.com//pull/548 Co-Authored-By: rlarkdfus <77201903+rlarkdfus@users.noreply.github.com>
|
Added to #620 |
* Move live price fetcher to its own process with rpc * Remove direct references for live price fetcher * Fix pickle generator bug * Fix test case * Add client connection retry and logging * Refactor to RPC server/client architecture and ServerOrchestrator pattern Major changes: - Implemented RPC server/client architecture for all major components - Added ServerOrchestrator singleton for centralized server lifecycle management - Migrated servers: LivePriceFetcher, PerfLedger, DebtLedger, ChallengePeriod, Elimination, PositionManager, Plagiarism, PlagiarismDetector, AssetSelection, LimitOrder, Contract, PositionLock, CoreOutputs, MinerStatistics - Added health monitoring and watchdog systems for all RPC servers - Implemented automatic restart and error recovery mechanisms - Added port management and shutdown coordination - Refactored test infrastructure to use ServerOrchestrator (50%+ faster test startup) - Added comprehensive RPC client/server base classes with connection retry logic - Implemented exponential backoff for failed operations - Created unified metagraph and common data servers - Added order processor and market order manager for limit order support - Enhanced position splitting and lock mechanisms - Improved test robustness with proper RPC method exposure - Added account_size parameter to Position for proper leverage validation - Updated all tests to maintain full robustness with RPC architecture Technical improvements: - Multiprocessing architecture for better isolation and stability - Standardized daemon patterns across all servers - Comprehensive health checks and monitoring - Automatic cleanup on process exit - Thread-safe singleton patterns - Reduced test execution time by sharing server infrastructure - Better error handling and logging throughout * test progress * fix miner. test progress * miner fixes. test progress 2 * fix 3 * debug receive signal * Fix * Fix dev endpoint * coldkey-hotkey verification RPC method * use websocket price fetching flow for quote and base usd conversions * Reapply order read changes * Correctly call live/historic prices for rest https: //github.com//pull/548 Co-Authored-By: rlarkdfus <77201903+rlarkdfus@users.noreply.github.com> * update live price fetcher rpc method signatures * Add signal field verifications * fix position inspector bug * misc test fixes * fix * fix * fix * fix * fixes, tests * fix payout * test progress. fix perf ledgers * no more pickle ledgers. TODO: Remove per-tp ledgers to reduce size. maybe sparse representation * debug * more logs * debug log * logs * metagraph robustness. more logs * more logs * logs * logs. priority ledger rebuild * debt ledger bug fix. * test progress * test fix * Connection cleanup * limit order daemon fix. test progress * test checkpoint. daemon centralization * Fix limit order tests, live price fetcher market patch not working * tests * tests * Fix market open call for test * tests, dev order api tier 200 * test * delete unused files * Cancel order by uuid from miner * write position inspector positions to file * Remove cancel by trade pair, only cancel by uuid * Fix tests * Fix api key tier for dev * Validate sltp fields on auto bracket creation from limit fill. * reorganize repo * unify order processing * Fix test * Validate bracket order after reading position direction * Add argparse import to emissions_ledger.py * miner does not require secrets file * Update sample signal and logs * Enforce asset selection for promotion Clear logging Include challenge period miners in promotion ranking Validate challenge miners being ranked has ledgers/positions Clean message * clean up validator.py and refactor. Use efficient RPC to get asset selection for a single miner * Include last place miner * remove copyright symbol causing encoding issues in github ci * mdd checker fix. logging fix * fix CI race condition? * cleanup/refactor/ test determinism * symbol cause github ci crash * test determinism * remove copyright symbol * fix name * no client for weight setter * refactor * rm dead code * ensure validator caches are pre-warmed before accepting orders. * fix price call. add price fetching tests. update debt based scoring to carry over PnL from Nov 1st for future calculations. * no client for weight setter * flat order with exact quantity and value but price diff for leverage * Skip saving limit order that fills immediately on disk * cleanup * tiingo batching to avoid 362|vanta | 2025-12-05 17:08:40.323 | WARNING | Tiingo crypto API request failed with status code 400. URL: https://api.tiingo.com/tiingo/crypto/prices?tickers=btcusd,ethusd,solusd,xrpusd,dogeusd,adausd,taous... Response: {"detail":"Error: A limit of 5 tickers may be requested at a time"} * stop populating websocket data for suspended/blocked trade pairs * fix tiingo url to be 1 min instead of 5 min. Fix lag calculation. Update tests in mdd checker --------- Co-authored-by: Jordan Bonilla <jbonilla@taoshi.io> Co-authored-by: sli-tao <sli@taoshi.io> Co-authored-by: rlarkdfus <77201903+rlarkdfus@users.noreply.github.com> Co-authored-by: jbonilla-tao <161871533+jbonilla-tao@users.noreply.github.com>
Taoshi Pull Request
Description
Pass order time for historic price calls / pass None for live price calls to data services.
Order times are unified to one timestamp for each trade pair.
Related Issues (JIRA)
[Reference any related issues or tasks that this pull request addresses or closes.]
Checklist
Reviewer Instructions
[Provide any specific instructions or areas you would like the reviewer to focus on.]
Definition of Done
Checklist (for the reviewer)
Optional: Deploy Notes
[Any instructions or notes related to deployment, if applicable.]
/cc @mention_reviewer